import request from '@/utils/request'

export function add(data) {
  return request({
    url: 'api/hazardousChemicals',
    method: 'post',
    data
  })
}

export function getListAPI (params) {
  return request({
    url: 'api/hazardousChemicals',
    method: 'get',
    params
  })
}

export function del(ids) {
  return request({
    url: 'api/hazardousChemicals/destroy',
    method: 'post',
    data: { ids } 
  })
}

export function edit(data) {
  return request({
    url: 'api/hazardousChemicals',
    method: 'put',
    data
  })
}

export function getStoreHouseAPI(type) {
  return request({
    url: 'api/hazardousChemicals/applyList',
    method: 'get',
    params: {
      type
    }
  })
}

export function getStoreHouseINfoAPI(type) {
  return request({
    url: 'api/hazardousChemicals/collect',
    method: 'get',
    params: {
      type
    }
  })
}

export function storehouseOrderAudit(params) {
  return request({
    url: 'api/storehouseOrder/audit',
    method: 'post',
    params
  })
}
//归还
export function returnHazardousChemicals (data) {
  return request({
    url: 'api/storehouseOrder/return',
    method: 'post',
    data
  })
}

export function rebackList(params) {
  return request({
    url: 'api/storehouseOrder/returnList',
    method: 'get',
    params
  })
}

export function getHazardousChemicals(data) {
  return request({
    url: 'api/hazardousChemicalsTotal/queryList',
    method: 'get',
    data
  })
}

export function searchId (id) {
  return request({
    url: 'api/storehouseOrder/auditList?id=' + id,
    method: 'get'
  })
}

/**
 * 获取有试剂柜的实验室
 * @returns
 */
export function getLabCabinetListAPI () {
  return request({
    url: 'api/lab/cabinetList',
    method: 'get'
  })
}

// 盘库根据id查
export function searchIdAndType (id, type) {
  return request({
    url: 'api/hazardousChemicalsTotal/list?id=' + id + '&type=' + type,
    method: 'get'
  })
}

// 模糊匹配查询名称
export function searchName (type) {
  return request({
    url: 'api/hazardousChemicals/queryNamesByType?type=' + type,
    method: 'get'
  })
}
//  入库接口
export function warehousingAPI (data) {
  return request({
    url: 'api/hazardousChemicals/warehousing',
    method: 'post',
    data
  })
}

// 通过id查询物质的信息
export function getHazardousChemicalsInfoByIdAPI (id) {
  return request({
    url: 'api/hazardousChemicals/queryNumByCode?id=' + id,
    method: 'get',
  })
}

// 销库burning
export function delBurningAPI (ids) {
  return request({
    url: 'api/hazardousChemicals/burning',
    method: 'post',
    data: ids
  })
}

// 盘库
export function pankuAPI (data) {
  return request({
    url: 'api/hazardousChemicals/panku',
    method: 'post',
    data
  })
}

export default { add, edit, del }
